Skip to content

Swift 3 API parity: Change type of HTTPURLResponse.allHeaderFields #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2016

Conversation

pushkarnk
Copy link
Member

@pushkarnk pushkarnk commented Aug 31, 2016

Change type of HTTPURLResponse.allHeaderFields to [AnyHashable : Any] to match Darwin.

@parkera
Copy link
Contributor

parkera commented Aug 31, 2016

@swift-ci please test linux

@@ -233,7 +233,8 @@ open class HTTPURLResponse : URLResponse {
/// This property is intended to produce readable output.
override open var description: String {
var result = "<\(type(of: self)) \(Unmanaged.passUnretained(self).toOpaque())> { URL: \(url!.absoluteString) }{ status: \(statusCode), headers {\n"
for(key, value) in allHeaderFields {
for(aKey, aValue) in allHeaderFields {
let (key,value) = (aKey as! String, aValue as! String) //allHeaderFields is either assigned a [String:String] or [:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we allow the header fields to be anything besides a string as part of the API, then shouldn't we use as? here? Otherwise we'll just assert in some cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, though allHeaderFields is always derived from a [String:String] we can have subclasses storing other types in it. I've updated the PR. Thanks.

@parkera
Copy link
Contributor

parkera commented Sep 6, 2016

@swift-ci please test linux

@parkera
Copy link
Contributor

parkera commented Sep 22, 2016

@swift-ci please test and merge

@swift-ci swift-ci merged commit c2ecbeb into swiftlang:master Sep 22, 2016
@pushkarnk pushkarnk deleted the httpurlresponse branch September 24, 2016 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants